package com.biblioteca.dao;

import com.biblioteca.persistencia.Noticia;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public class NoticiaDaoImplementacion extends GenericDaoImplementation<Noticia, Long> implements NoticiaDao {

    @Transactional
    @Override
    public List<Noticia> getNoticiasOrdenadas() {
        final StringBuilder sql = new StringBuilder("select c from Noticia c ORDER by fecha DESC");
        return (List<Noticia>) em.createQuery(sql.toString()).getResultList();
    }   
}
